#include "thread_pool.hpp"
#include "events_base.hpp"
#include "error_check.hpp"

#include <signal.h>

#include <glog/logging.h>
#include "cdb_pool.hpp"
void setLog()
{
    FLAGS_v = 2;
    FLAGS_logtostderr = false;
    FLAGS_log_dir = "/home/chen/cpp/cpp2/test9/log";
    FLAGS_max_log_size = 100;
}
int main(int argc,char **argv)
{   std::string db_pool_name = DB_POOL_NAME;
    std::string db_server_ip = DB_SERVER_IP;
    std::string db_database_name = DB_DATABASE_NAME;
    std::string db_username = DB_USERNAME;
    std::string db_pasword = DB_PASSWORD;
    int db_pool_max_count = DB_POOL_MAX_COUNT;
    unsigned int db_server_port = DB_SERVER_PORT;

    cdb_pool* pools = cdb_pool::getInstance(db_pool_name,db_server_ip,
                                            db_server_port,db_database_name,
                                            db_username,db_pasword,
                                            db_pool_max_count);
    pools->init();
    FLAGS_alsologtostderr = 1;
    if(signal(SIGPIPE, SIG_IGN) == SIG_ERR)
		return 1;
    FLAGS_logtostderr = 1;
	google::InitGoogleLogging(argv[0]);
    setLog();
    thread_pool * pool = thread_pool::getInstance();
    pool->init(5);
    //
    events_base* base = new events_base();
    base->event_init();
    base->event_run();
    getchar();

}